package com.info.widgets.Pennyoffer;

import java.util.ArrayList;
import java.util.List;
import java.sql.*;

import com.info.widgets.ConnectionHelper;
import com.info.widgets.DAOException;
import com.info.widgets.Pennyoffer.Pennyoffer;

public class PennyofferService {
	
	
	
	
	public ArrayList<Pennyoffer> pennyCreation (Pennyoffer Penny) throws DAOException{
		System.out.println("PennyCreation");
		Pennyoffer penny1= new Pennyoffer();
		
		Connection con=null;
		String dbtime=null;
		//String query="SELECT * FROM mycaspian.pennyoffer";
		ArrayList<Pennyoffer> arrayList = new ArrayList<Pennyoffer>();
		try {
			
			con=ConnectionHelper.getConnection();
			Statement stmt=con.createStatement();
			//ResultSet rs=stmt.executeQuery(query);
			PreparedStatement pst = null;
			
			
			pst = con.prepareStatement("INSERT INTO Pennyoffer (firstname, lastname, emailaddress, companyname, phone, contactname, contactemail, leadcompany, leadcontact, title, leadphone, leademail, projectdate, qualityofemployees) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
			 
			pst.setString(1,Penny.getFirstname());
			pst.setString(2,Penny.getLastname());
			pst.setString(3, Penny.getEmailaddress());
			
			pst.setString(4,Penny.getCompanyname());
			pst.setLong(5, Penny.getPhone());
			pst.setString(6,Penny.getContactemail());
			pst.setString(7,Penny.getContactname());
			pst.setString(8,Penny.getLeadcompany());
			pst.setString(9,Penny.getLeadcontact());
			pst.setLong(10,Penny.getProjectdate());
			pst.setLong(11, Penny.getQualityofemployees());
			
			
			
			
			pst.executeUpdate();
			} catch (Exception e) {
			e.printStackTrace();
			throw new DAOException(e);
		} finally {
			ConnectionHelper.close(con);
		}
		return arrayList;
		 
	}
}